
#include "bullet1.h"

#include "bullet1.h"
#include"config.h"
bullet1::bullet1()
{
    //加载子弹资源
        m_bullet1.load(BULLET_PATH1);
    //子弹坐标
        m_X=GAME_WIDTH *0.5-m_bullet1.width()*0.5;
         m_Y=GAME_HEIGHT;

         //子弹状态  默认空闲
         m_Free=true;

         //子弹速度
         m_Speed= BULLET_SPEED;

         //子弹边框
         m_Rect.setWidth(m_bullet1.width());
         m_Rect.setHeight(m_bullet1.height());
         m_Rect.moveTo(m_X,m_Y);
}

void bullet1::updatePosition()
{
    if(m_Free){
        return;
    }
    //子弹向下移动
    m_Y+=m_Speed;
    m_Rect.moveTo(m_X,m_Y);
    if(m_Y>700+m_Rect.height()){
        //子弹位置超出屏幕，重新变为空闲状态
        m_Free=true;
    }

}
